<?php 
/**
* @orm tableName forum_images
* @orm listener beforeInsert beforeInsert
*/
class ForumImage extends DomArObject {
	
	/**
	* @orm plugin DomArImage({autoRename=1r})
	* @orm listener afteradd afterAddImage
	*/
	public $image;
	/**
	* @orm plugin DomArImage({autoRename=1r})
	*/
	public $icon;
	/**
	* @orm text
	*/
	public $title;
	
	
	public function afterAddImage() {
		if( $this->image->exists() ) {
			$this->image->resize(800,600);
			$this->icon = $this->image->copy();
			$this->icon->resize(100,80, false);
			$this->icon->cut(100,80);	
			$this->image->rename('tmp/');
			$this->icon->rename('tmp/');
			$this->image->watermark( DOM_MEDIA_DIR . 'Buduaar/watermark.png', array('alpha' => 30, 'position' => 'br') );
		}
	}
	
	public function beforeInsert() {
		if( $this->image->exists() ) {
			$this->image->rename('/');
			$this->icon->rename('/');
		}
	}
}
?>